package com.itheima.tlias.controller;

import com.alibaba.fastjson.JSONObject;
import com.itheima.tlias.util.ResultUtil;
import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("session")
public class TestSessionController {

    @GetMapping("save")
    public ResultUtil saveSession(HttpSession session) {
        session.setAttribute("username", "summer");
        session.setAttribute("password", "123456");
        return ResultUtil.success();
    }

    @GetMapping("get")
    public ResultUtil getSession(HttpSession session) {
        session.getAttribute("username");
        session.getAttribute("password");
        return ResultUtil.success();
    }
}
